//------------Sonic CD Tunnel Path Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 65: TYPE_TUNNELPATH
#alias Player.Value4:Player.Invincible
#alias Player.Value5:Player.BlinkTimer


sub ObjectMain
	if Object.State==1
		if Player.State==PlayerObject_Death
			Object.State=0
		endif
		TempValue0=Object.Value0
		Object.Value0++
		Player.Speed=Player.XPos
		Player.Visible=0
		switch TempValue0
		case 0
			Player.ObjectInteraction=0
			Player.XPos=334541056
			Player.YPos=15754496
			break
		case 1
			Player.XPos=335589632
			Player.YPos=15754496
			break
		case 2
			Player.XPos=336638208
			Player.YPos=15754496
			break
		case 3
			Player.XPos=337686784
			Player.YPos=15754496
			break
		case 4
			Player.XPos=338735360
			Player.YPos=15754496
			break
		case 5
			Player.XPos=339783936
			Player.YPos=15754496
			break
		case 6
			Player.XPos=340832512
			Player.YPos=16203776
			break
		case 7
			Player.XPos=341881088
			Player.YPos=16653056
			break
		case 8
			Player.XPos=342929664
			Player.YPos=17102336
			break
		case 9
			Player.XPos=343453952
			Player.YPos=17364480
			break
		case 10
			Player.XPos=343903232
			Player.YPos=18413056
			break
		case 11
			Player.XPos=344352512
			Player.YPos=19461632
			break
		case 12
			Player.XPos=344801792
			Player.YPos=20510208
			break
		case 13
			Player.XPos=344998400
			Player.YPos=21034496
			break
		case 14
			Player.XPos=344998400
			Player.YPos=22083072
			break
		case 15
			Player.XPos=344998400
			Player.YPos=23131648
			break
		case 16
			Player.XPos=344998400
			Player.YPos=24180224
			break
		case 17
			Player.XPos=344998400
			Player.YPos=25228800
			break
		case 18
			Player.XPos=344998400
			Player.YPos=26277376
			break
		case 19
			Player.XPos=344998400
			Player.YPos=27325952
			break
		case 20
			Player.XPos=344998400
			Player.YPos=28374528
			break
		case 21
			Player.XPos=344998400
			Player.YPos=29423104
			break
		case 22
			Player.XPos=344998400
			Player.YPos=30471680
			break
		case 23
			Player.XPos=344998400
			Player.YPos=31520256
			break
		case 24
			Player.XPos=343949824
			Player.YPos=31834624
			break
		case 25
			Player.XPos=342901248
			Player.YPos=32148992
			break
		case 26
			Player.XPos=341852672
			Player.YPos=32463360
			break
		case 27
			Player.XPos=340804096
			Player.YPos=32777728
			break
		case 28
			Player.XPos=339755520
			Player.YPos=33092096
			break
		case 29
			Player.XPos=338706944
			Player.YPos=32698880
			break
		case 30
			Player.XPos=337658368
			Player.YPos=32305664
			break
		case 31
			Player.XPos=336609792
			Player.YPos=31912448
			break
		case 32
			Player.XPos=335561216
			Player.YPos=31519232
			break
		case 33
			Player.XPos=335036928
			Player.YPos=30470656
			break
		case 34
			Player.XPos=334512640
			Player.YPos=29422080
			break
		case 35
			Player.XPos=334512640
			Player.YPos=28373504
			break
		case 36
			Player.XPos=334512640
			Player.YPos=27324928
			break
		case 37
			Player.XPos=334512640
			Player.YPos=26276352
			break
		case 38
			Player.XPos=334512640
			Player.YPos=25227776
			break
		case 39
			Player.XPos=335561216
			Player.YPos=24179200
			break
		case 40
			Player.XPos=336609792
			Player.YPos=23917056
			break
		case 41
			Player.XPos=337658368
			Player.YPos=23654912
			break
		case 42
			Player.XPos=338706944
			Player.YPos=23917056
			break
		case 43
			Player.XPos=339755520
			Player.YPos=24179200
			break
		case 44
			Player.XPos=340504320
			Player.YPos=25227776
			break
		case 45
			Player.XPos=341253120
			Player.YPos=26276352
			break
		case 46
			Player.XPos=342001920
			Player.YPos=27324928
			break
		case 47
			Player.XPos=342395136
			Player.YPos=27849216
			break
		case 48
			Player.XPos=343443712
			Player.YPos=28082176
			break
		case 49
			Player.XPos=344492288
			Player.YPos=28315136
			break
		case 50
			Player.XPos=345540864
			Player.YPos=28548096
			break
		case 51
			Player.XPos=346589440
			Player.YPos=28781056
			break
		case 52
			Player.XPos=347638016
			Player.YPos=29014016
			break
		case 53
			Player.XPos=348686592
			Player.YPos=29246976
			break
		case 54
			Player.XPos=349735168
			Player.YPos=29479936
			break
		case 55
			Player.XPos=350783744
			Player.YPos=29712896
			break
		case 56
			Player.XPos=351832320
			Player.YPos=29945856
			break
		case 57
			Player.XPos=352880896
			Player.YPos=30178816
			CreateTempObject(TypeName[WaterfallSplash],0,Player.XPos,Player.YPos)
			break
		case 58
			Player.XPos=353929472
			Player.YPos=30411776
			break
		case 59
			Player.XPos=354978048
			Player.YPos=30644736
			break
		case 60
			Player.XPos=356026624
			Player.YPos=30877696
			CreateTempObject(TypeName[WaterfallSplash],0,Player.XPos,Player.YPos)
			break
		case 61
			Player.XPos=357075200
			Player.YPos=31110656
			break
		case 62
			Player.XPos=358123776
			Player.YPos=31343616
			break
		case 63
			Player.XPos=359172352
			Player.YPos=31576576
			CreateTempObject(TypeName[WaterfallSplash],0,Player.XPos,Player.YPos)
			break
		case 64
			Player.XPos=360220928
			Player.YPos=31809536
			break
		case 65
			Player.XPos=361269504
			Player.YPos=32042496
			break
		case 66
			Player.XPos=362318080
			Player.YPos=32275456
			CreateTempObject(TypeName[WaterfallSplash],0,Player.XPos,Player.YPos)
			break
		case 67
			Player.XPos=363366656
			Player.YPos=32508416
			break
		case 68
			Player.XPos=364415232
			Player.YPos=32741376
			break
		case 69
			Player.XPos=365463808
			Player.YPos=32974336
			break
		case 70
			Player.XPos=366512384
			Player.YPos=33207296
			break
		case 71
			Player.XPos=368609536
			Player.YPos=33673216
			break
		case 72
			Player.XPos=369658112
			Player.YPos=33906176
			break
		case 73
			Player.XPos=370706688
			Player.YPos=34139136
			break
		case 74
			Player.XPos=371755264
			Player.YPos=34372096
			break
		case 75
			Player.XPos=372803840
			Player.YPos=34605056
			break
		case 76
			Player.XPos=373852416
			Player.YPos=34838016
			break
		case 77
			Player.XPos=374900992
			Player.YPos=35070976
			break
		case 78
			Player.XPos=375425280
			Player.YPos=35136512
			break
		case 79
			Player.XPos=376473856
			Player.YPos=35005440
			break
		case 80
			Player.XPos=377522432
			Player.YPos=34874368
			break
		case 81
			Player.XPos=378571008
			Player.YPos=34743296
			break
		case 82
			Player.XPos=379619584
			Player.YPos=34612224
			break
		case 83
			Player.XPos=380668160
			Player.YPos=33825792
			break
		case 84
			Player.XPos=381716736
			Player.YPos=33039360
			break
		case 85
			Player.XPos=382066176
			Player.YPos=31990784
			break
		case 86
			Player.XPos=382415616
			Player.YPos=30942208
			break
		case 87
			Player.XPos=382765056
			Player.YPos=29893632
			break
		case 88
			Player.XPos=382240768
			Player.YPos=28845056
			break
		case 89
			Player.XPos=381716480
			Player.YPos=27796480
			break
		case 90
			Player.XPos=380667904
			Player.YPos=27534336
			break
		case 91
			Player.XPos=379619328
			Player.YPos=27272192
			break
		case 92
			Player.XPos=378570752
			Player.YPos=27010048
			break
		case 93
			Player.XPos=377522176
			Player.YPos=26747904
			break
		case 94
			Player.XPos=376473600
			Player.YPos=26957568
			break
		case 95
			Player.XPos=375425024
			Player.YPos=27167232
			break
		case 96
			Player.XPos=374900736
			Player.YPos=27298304
			break
		case 97
			Player.XPos=374271744
			Player.YPos=28346880
			break
		case 98
			Player.XPos=373642752
			Player.YPos=29395456
			break
		case 99
			Player.XPos=373315072
			Player.YPos=29919744
			break
		case 100
			Player.XPos=373734400
			Player.YPos=30968320
			break
		case 101
			Player.XPos=374153728
			Player.YPos=32016896
			break
		case 102
			Player.XPos=374350336
			Player.YPos=32541184
			break
		case 103
			Player.XPos=375398912
			Player.YPos=32890624
			break
		case 104
			Player.XPos=376447488
			Player.YPos=33240064
			break
		case 105
			Player.XPos=377496064
			Player.YPos=33589504
			break
		case 106
			Player.XPos=378544640
			Player.YPos=33589504
			break
		case 107
			Player.XPos=379593216
			Player.YPos=33589504
			break
		case 108
			Player.XPos=380641792
			Player.YPos=33589504
			break
		case 109
			Player.XPos=381690368
			Player.YPos=33589504
			break
		case 110
			Player.XPos=382738944
			Player.YPos=34638080
			break
		case 111
			Player.XPos=382738944
			Player.YPos=35686656
			break
		case 112
			Player.XPos=382738944
			Player.YPos=36735232
			break
		case 113
			Player.XPos=382738944
			Player.YPos=37783808
			break
		case 114
			Player.XPos=382738944
			Player.YPos=38832384
			break
		case 115
			Player.XPos=382738944
			Player.YPos=39880960
			break
		case 116
			Player.XPos=382738944
			Player.YPos=40929536
			break
		case 117
			Player.XPos=382738944
			Player.YPos=41978112
			break
		case 118
			Player.XPos=382738944
			Player.YPos=42502400
			break
		case 119
			Player.XPos=382439424
			Player.YPos=43550976
			break
		case 120
			Player.XPos=382139904
			Player.YPos=44599552
			break
		case 121
			Player.XPos=381840384
			Player.YPos=45648128
			break
		case 122
			Player.XPos=381709312
			Player.YPos=46172416
			break
		case 123
			Player.XPos=380660736
			Player.YPos=46565632
			break
		case 124
			Player.XPos=379612160
			Player.YPos=46958848
			break
		case 125
			Player.XPos=378563584
			Player.YPos=47352064
			break
		case 126
			Player.XPos=377515008
			Player.YPos=47745280
			break
		case 127
			Player.XPos=376466432
			Player.YPos=47220992
			break
		case 128
			Player.XPos=375417856
			Player.YPos=46696704
			break
		case 129
			Player.XPos=374369280
			Player.YPos=46172416
			break
		case 130
			Player.XPos=374369280
			Player.YPos=45123840
			break
		case 131
			Player.XPos=374369280
			Player.YPos=44075264
			break
		case 132
			Player.XPos=375417856
			Player.YPos=43725824
			break
		case 133
			Player.XPos=376466432
			Player.YPos=43376384
			break
		case 134
			Player.XPos=377515008
			Player.YPos=43026944
			break
		case 135
			Player.XPos=378563584
			Player.YPos=43026944
			break
		case 136
			Player.XPos=379612160
			Player.YPos=43026944
			break
		case 137
			Player.XPos=380660736
			Player.YPos=43026944
			break
		case 138
			Player.XPos=381709312
			Player.YPos=43026944
			break
		case 139
			Player.XPos=382757888
			Player.YPos=43026944
			break
		case 140
			Player.XPos=383806464
			Player.YPos=43026944
			break
		case 141
			Player.XPos=384855040
			Player.YPos=43026944
			break
		case 142
			Player.XPos=385903616
			Player.YPos=43026944
			break
		case 143
			Player.XPos=386952192
			Player.YPos=43446272
			break
		case 144
			Player.XPos=388000768
			Player.YPos=43865600
			break
		case 145
			Player.XPos=388525056
			Player.YPos=44062208
			break
		case 146
			Player.XPos=388525056
			Player.YPos=45110784
			break
		case 147
			Player.XPos=388525056
			Player.YPos=46159360
			break
		case 148
			Player.XPos=388525056
			Player.YPos=47207936
			break
		case 149
			Player.XPos=388525056
			Player.YPos=48256512
			break
		case 150
			Player.XPos=387476480
			Player.YPos=48675840
			break
		case 151
			Player.XPos=386427904
			Player.YPos=49095168
			break
		case 152
			Player.XPos=385903616
			Player.YPos=49291776
			break
		case 153
			Player.XPos=384855040
			Player.YPos=48662528
			break
		case 154
			Player.XPos=383818240
			Player.YPos=48560384
			break
		case 155
			Player.Visible=1
			Player.TileCollisions=1
			Object.State=0
			Object.Priority=0
			Player.XVelocity=-786432
			Player.Speed=-786432
			Player.State=PlayerObject_HandleGround
			Player.ObjectInteraction=1
			if Object[+1].Type==TypeName[BlankObject]
				Object[+1].Type=TypeName[TunnelPath]
				PlayStageSfx(0,0)
			endif
			break

		endswitch
		if Object.State>0
			Player.Speed-=Player.XPos
			FlipSign(Player.Speed)
		endif
	endif
endsub


sub ObjectPlayerInteraction
	if Object.PropertyValue==0
		if Player.State!=PlayerObject_Blank
			PlayerObjectCollision(C_TOUCH,-16,-16,16,16)
			if CheckResult==1
				Player.State=PlayerObject_Blank
				if Player.BlinkTimer>0
					Player.Invincible=0
					Player.BlinkTimer=0
				endif
				Player.TileCollisions=0
				Player.Visible=0
				Object.State=1
				Object.Value0=0
				Object.Priority=1
				PlaySfx(7,0)
			endif
		endif
	endif
endsub


sub ObjectDraw
	if Object.PropertyValue>0
		DrawSprite(0)
	endif
endsub


sub ObjectStartup
	if Stage.PlayerListPos==0
		LoadSpriteSheet("R1/Objects.gif")
		SpriteFrame(-16,-16,32,32,34,175)
	else
		LoadSpriteSheet("R1/Objects3.gif")
		SpriteFrame(-14,-16,29,32,115,167)
	endif
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
